<template>
	<view class="page">
		<!-- <view class="flex benben-position-layout flex flex-wrap align-center testExamination_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub testExamination_fd0_0'>
				<view class='flex flex-wrap align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  testExamination_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<text class='testExamination_fd0_0_c1'>选择门店</text>
				<view class='flex flex-wrap align-center testExamination_fd0_0_c2'>
				</view>
			</view>
		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view> -->

		<view class="scroll_content" :style="{height: pageHeight + 'rpx'}">
			<scroll-view :scroll-y="true" class="scroll_le">
				<view class="city_item flex align-center justify-center" v-for="(item, index) in cityList" :key="index"
					@tap.stop="selectCity(item.id, item.name)">
					<view class="city_item_1" v-if="city_id == item.id"></view>
					<view class="city_item_2" :class="city_id == item.id ? 'active_city' : ''">{{item.name}}{{item.id ? '市' : ""}}</view>
				</view>
			</scroll-view>
			<scroll-view :scroll-y="true" class="scroll_ri">
				<view class="loading_view" v-if="isShow">
					<u-loading size="36" color="#FC5B03"></u-loading>
					<view>加载中</view>
				</view>
				<template v-else>
					<view class="store_item flex align-center" v-for="(v, k) in storeList" :key="k"
						@tap.stop="selectStore(v.id, v.name, v.lng, v.lat, v.city_id)">
						<u-lazy-load class="store_img" mode="aspectFill" height="160" border-radius="8" :image="v.image"
							:loading-img="loadingImg" :error-img="errorImg"></u-lazy-load>
						<view class="store_view">
							<view class="store_title">{{v.name}}</view>
							<view class="store_address">{{v.address}}</view>
							<view class="store_icon flex align-center">
								<image @tap.stop="openLocation(v.lat, v.lng)" class="icon_1" :src='STATIC_URL+"267.png"'
									mode="aspectFill"></image>
								<view class="icon_line"></view>
								<image @tap.stop="getPhone(v.phone)" class="icon_1" :src='STATIC_URL+"268.png"'
									mode="aspectFill"></image>
							</view>
						</view>
					</view>
					<view class="noData_other" v-if="storeList.length == 0 && !isShow">
						<image :src='STATIC_URL+"no.png"'></image>
						<view>暂无门店~</view>
					</view>
				</template>

			</scroll-view>
		</view>
	</view>
</template>
<script>
	export default {
		components: {},

		data() {
			return {
				"pageHeight": 0,
				"city_id": 0,
				"loadingImg": "",
				"errorImg": "",
				"imageUrl": "https://n.sinaimg.cn/spider20240423/618/w1267h951/20240423/00f3-b0424ba924fbe8bb330e2dabf0f7b880.jpg",
				"cityList": [], // 城市列表
				"storeList": [], // 门店列表
				"isShow": true,
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			setTimeout(() => {
				this.pageHeight = this.pxToRpx(uni.getSystemInfoSync().windowHeight);
			}, 300)
			this.getCityList();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// uni.upx2px
			pxToRpx(px) {
				let scale = uni.upx2px(100) / 100;
				return px / scale
			},
			selectCity(id, name) {
				this.city_id = id;
				this.city_name = name;
				this.isShow = true;
				this.getStoreList();
			},
			selectStore(id, name, lng, lat, city_id) {
				let storeInfo = {
					store_id: id,
					store_name: name,
					citycode: city_id,
					lng: lng,
					lat: lat
				}
				uni.setStorageSync('store', storeInfo);
				uni.navigateBack();
			},
			// 获取城市列表  postCityInfo
			getCityList() {
				this.$api.get(global.apiUrls.postCityInfo, {}).then(res => {
					console.log(res);
					if (res.data.code == 1) {
						this.cityList = res.data.data;
						this.cityList.unshift({
							id: 0,
							name: '全部'
						})
						// if (this.cityList.length > 0) {
						// 	if (uni.getStorageSync('store')) {
						// 		this.city_id = uni.getStorageSync('store').citycode;
						// 	} else {
						// 		let city = uni.getStorageSync('city');
						// 		if (city) {
						// 			let city_id = "";
						// 			this.cityList.forEach((v, k) => {
						// 				if (v.id == city.citycode) {
						// 					city_id = v.id;
						// 				}
						// 			})
						// 			if (city_id) {
						// 				this.city_id = city_id;
						// 			} else {
						// 				// this.city_id = 268;
						// 				this.city_id = 0;
						// 			}
									
						// 		} else {
						// 			// this.city_id = this.cityList[0].id;
						// 			// this.city_id = 268;
						// 			this.city_id = 0;
						// 		}
						// 	}
						// }
						this.getStoreList();
					} else {
						this.$message.info(res.data.info);
					}
				})
			},
			// 获取门店列表
			getStoreList() {
				this.$api.get(global.apiUrls.getCarStore, {
					city_id: this.city_id ? this.city_id : ""
				}).then(res => {
					console.log(res);
					this.isShow = false;
					if (res.data.code == 1) {
						this.storeList = res.data.data;
					} else {
						this.$message.info(res.data.info);
					}
				})
			},
			// 打开地图
			openLocation(lat, lng) {
				uni.openLocation({
					latitude: lat,
					longitude: lng,
					success: function() {
						console.log('success');
					},
					fail: function() {
						
					}
				});
			},

			// 拨打电话
			getPhone(phone) {
				if (!phone) {
					this.$message.info('未获取到门店联系方式，请联系客服');
					return;
				}
				uni.makePhoneCall({
					phoneNumber: phone,//仅为示例,
					success: err => {
						
					},
					fail: err => {
						console.log(err);
					}
				});
			},
		}
	};
</script>
<style lang="scss" scoped>
	.loading_view {
		text-align: center;
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);

		view {
			color: #999999;
			font-size: 22rpx;
			margin-top: 16rpx;
		}
	}

	.scroll_content {
		display: flex;

		.scroll_le {
			height: 100%;
			width: 160rpx;
			background: #fff;

			.city_item {
				padding: 32rpx 16rpx;
				position: relative;

				.city_item_1 {
					width: 6rpx;
					height: 32rpx;
					background: #FC5B03;
					border-radius: 0px 4rpx 4rpx 0px;
					position: absolute;
					left: 0;
					top: 50%;
					transform: translateY(-50%);
				}

				.city_item_2 {
					font-weight: 500;
					font-size: 30rpx;
					color: #666666;
					line-height: 35rpx;
				}

				.active_city {
					font-weight: 500;
					font-size: 30rpx;
					color: #111111;
					line-height: 35rpx;
				}
			}
		}

		.scroll_ri {
			height: 100%;
			padding: 0 18rpx 16rpx 16rpx;
			position: relative;
			flex: 1;
			.store_item {
				background: #FFFFFF;
				border-radius: 16rpx;
				border: 2rpx solid #ECEEF4;
				padding: 24rpx 20rpx;
				margin-top: 20rpx;

				.store_img {
					width: 160rpx;
					height: 160rpx;
				}

				.store_view {
					width: calc(100% - 160rpx);
					padding-left: 16rpx;

					.store_title {
						font-weight: bold;
						font-size: 30rpx;
						color: #111111;
						text-overflow: ellipsis;
						overflow: hidden;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 1;
					}

					.store_address {
						margin: 8rpx 0 10rpx;
						height: 60rpx;
						font-weight: 400;
						font-size: 22rpx;
						color: #999999;
						line-height: 26rpx;
						text-overflow: ellipsis;
						overflow: hidden;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 2;
					}

					.store_icon {
						.icon_1 {
							width: 48rpx;
							height: 48rpx;
						}

						.icon_line {
							width: 2rpx;
							height: 32rpx;
							background: #E7E7E7;
							margin: 0 24rpx;
						}
					}
				}

				/deep/.u-lazy-item {
					width: 160rpx !important;
					height: 160rpx !important;
				}
			}
		}
	}

	.personalInformation_fd1_0 {
		padding: 28rpx 0;
		border-top: 2rpx solid #eee;
	}

	.personalInformation_fd1_0_c0 {
		font-size: 28rpx;
		color: rgba(0, 0, 0, 0.6);
	}

	.personalInformation_fd1_1_c1 {
		font-size: 28rpx;
		font-weight: 400;
		color: #111;
		text-align: right;
	}


	.feedback_fd4_0 {
		width: 640rpx;
		border-radius: 80rpx;
		font-size: 30rpx;
		font-weight: bold;
		color: #fff;
		margin: 0rpx 32rpx 0rpx 32rpx;
		height: 84rpx;
		line-height: 84rpx;
		text-align: center;
		background: #FC5B03;
	}

	.feedback_flex_4 {
		width: 750rpx;
		height: 120rpx;
		overflow: hidden;
		position: fixed;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		display: flex;
		justify-content: center;
		background: #fff;
	}




	.testExamination_fd1_0 {
		margin: 0rpx 16rpx 0rpx 0rpx;
		padding: 40rpx 32rpx 24rpx 32rpx;
	}

	.testExamination_fd1_0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.testExamination_fd1_0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: #333333;
	}

	.testExamination_notAnfd1_1_c0 {
		background: rgba(244, 250, 255, 1);
		background-size: 100% !important;
		width: 750rpx;
		height: 80rpx;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.testExamination_anfd1_1_c0 {
		background: rgba(244, 250, 255, 1);
		background-size: 100% !important;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
		width: 750rpx;
		height: 80rpx;
	}

	.testExamination_areafd1_1_c0 {
		min-height: 80rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.testExamination_notAnfd1_1_c0_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.testExamination_notAnfd1_1_c0_c0_c1 {
		margin: 0rpx 20rpx 0rpx 0rpx;
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: #1593FF;
	}

	.testExamination_notAnfd1_1_c0_c0_c2 {
		font-weight: 700;
		font-size: 32rpx;
		color: #1593FF;
		line-height: 45rpx;
		text-decoration: none;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.testExamination_anfd1_1_c0_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.testExamination_anfd1_1_c0_c0_c1 {
		margin: 0rpx 20rpx 0rpx 0rpx;
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: #1593FF;
	}

	.testExamination_anfd1_1_c0_c0_c2 {
		font-weight: 700;
		font-size: 32rpx;
		color: #1593FF;
		line-height: 45rpx;
		text-decoration: none;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.testExamination_areafd1_1_c0_c0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 40rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c0_c0 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		margin: 0rpx 15rpx 0rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c0_c1 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c0 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(21, 147, 255, 1);
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c1 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c2 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c3 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		margin: 0rpx 32rpx 0rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c4 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c5 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c1 {
		font-size: 26rpx;
		color: rgba(191, 191, 191, 1);
	}

	.testExamination_areafd1_1_c0_c0_c1 {
		background: rgba(242, 242, 242, 1);
		background-size: 100% !important;
		width: 602rpx;
		height: 16rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		background-size: 100% auto !important;
	}

	.testExamination_progress1_areafd1_1_c0_c0_c1 {
		background: rgba(21, 147, 255, 1);
		background-size: 100% !important;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
	}

	.testExamination_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.testExamination_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #111;
	}

	.testExamination_fd0_0_c1 {
		font-size: 32rpx;
		font-weight: bold;
		color: #111111;
	}

	.testExamination_fd0_0_c2 {
		width: 36rpx;
		height: 36rpx;
	}

	.testExamination_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		background-size: 100% !important;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.page {
		// min-height: calc(100vh - var(--window-bottom));
		background: #f6f7fb;
		background-size: 100% auto !important;
	}
</style>